﻿using System.Collections.Generic;
using BoutiquePOS.DAL.DAO;
using BoutiquePOS.DAL.Gateway;

namespace BoutiquePOS.Manager
{
    public class RackManager
    {
        RackGateway rackGateway = new RackGateway();

        public string SaveRack(Rack rack)
        {
            if (!DoesThisRackExist(rack))
                return rackGateway.SaveRack(rack);
            else
            {
                return "This rack Already Exists";
            }
        }
        private bool DoesThisRackExist(Rack rack)
        {
            List<Rack> racks = new List<Rack>();
            racks = rackGateway.GetAllRack();

            foreach (Rack rackObj in racks)
            {
                if (rackObj.RackName == rack.RackName)
                    return true;
            }
            return false;
        }
        public List<Rack> GetAllRack()
        {
            return rackGateway.GetAllRack();
        }
        public string DeleteRack(int rackId)
        {
            string message = rackGateway.DeleteRackById(rackId);
            return message;
        }
        public List<Rack> GetAllRackByIdOrName(int i, string Id)
        {
            return rackGateway.GetAllRackByCodeOrName(i, Id);
        }
    }
}